Why do int when add up in java keeps on adding? [closed]
Posted
by
Trycon
on Programmers
See other posts from Programmers
or by Trycon
Published on 2012-10-22T11:37:35Z
Indexed on
2012/10/22
17:18 UTC
Read the original article
Hit count: 137
java
I'm developing a game. I'm really new in java and researched google: why does an int when added, keeps on adding java
Most of the times, it always adds even:
STOP_DAMAGE+=1;
Even sometimes, it subtract till negative. I'm annoyed. Sometimes it doesn't add too much. I do not understand. Here is my code:
if(isPressed==true)
{
if(STOP_DAMAGE<=5)
{
if(WAIT_DAMAGE>=3000)
{
ENEMY_SHIP_HEALTH-=SHIP_DAMAGE_ENEMY;
STOP_DAMAGE+=1;
}
}
}
for(;WAIT_DAMAGE>=3003;)
{
WAIT_DAMAGE-=WAIT_DAMAGE;//time is deducted
}
//WAIT_DAMAGE is a time int
© Programmers or respective owner